package tiruvury.InterviewPrep.HelperClasses;

import java.util.Comparator;

public class MaxHeapComparator implements Comparator<Integer>
{
	public int compare(Integer x, Integer y)
	{
		if (x.intValue() == y.intValue())
		{
			return 0;
		}
		/*
		 * CODINGERROR:
		 * You initially got the sign wrong.
		 * For min-heap i.e. the default implementation, x > y returns 1;
		 * For max-heap i.e. the custom implementation, y > x returns 1;
		 * 
		 * You can also write this whole thing as: return y - x
		 */
		else if (x.intValue() < y.intValue())
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}
}